﻿Chenxin.UI.ShowListEmployee = Chenxin.extend(Chenxin.UI.PageCommon,{
    autoInitForm:false,
    actionUrl:'/service/logic/ShowListEmployee.ashx',
    createSearch:function(){
        return new Chenxin.UI.ShowListEmployeeSearch({
            scope: this
        });
    },
    createGrid: function() {
        _this = this;
        return new Chenxin.UI.JsonGrid({
            createTitleTool: function() {
                return [{
                    text: '<span id="" class="x-grid-export" style="width:90px" title="导出全部数据">导出全部数据</span>',
                    scope: this,
                    title: '导出全部数据',
                    handler: function(el) {
                        _this.exportAll();
                    }
                }];
            },
            actionUrl: this.actionUrl + '?op=search',
            id: 'ShowListEmployee_table',
            renderTo: 'ShowListEmployee_table',
            hasCheckBox:false,
			cellBorder:true,
			scope:this,
			pageSize: 50,
			height: 400,
			autoLoad: false,
			modelId:'RecordId',
            columns: {
                RecordId:{
					create:false,
					head:'id'
				},
                City: {
                    head: '城市',
                    width: 50
                },
                Company: {
                    head: '公司',
                    width: 70
                },
                Businessdistrict: {
                    head: '商圈',
                    width: 100
                },
                Departs: {
                    head: '部门',
                    width: 120
                },
                EmployeeCode: {
                    head: '工号',
                    width: 100
                },
                Employee: {
                    head: '姓名',
                    width: 70
                },
                Position: {
                    head: '职务',
                    width: 80
                },
                BeginTime: {
                    head: '开始时间',
                    width: 80
                },
                EndTime: {
                    head: '结束时间',
                    width: 80
                },
                ChangType: {
                    head: '变动类型',
                    width: 80
                },
                TransType: {
                    head: '变动名称',
                    width: 80
                },
                PeopleNum: {
                    head: '人数',
                    width: 50
                },
                YearMonth: {
                    head: '年月',
                    width: 80
                }
            }
        });
    },
    loadinfo: function() {
        var _this = this;
        Chenxin.ajax({
            type: "get",
            dataType: "text",
            paramType: 'json',
            async:false,
            url: this.actionUrl,
            data: { op: 'getmodel', modelid: this.currentId },
            onSuccess: function(data, msg) {
                if (data) {
                    _this.currentNum = data;
                }
            }
        });
    },
    initEvent:function(){
        var _this = this;
        
        /*************************事件：人效修改************************/
        $("#aChgNum").click(function(){
            //人效显示
            if (_this.currentId == null || _this.currentId == "") {
                alert("请先选择一条人效记录！");
                return;
            }
            _this.loadinfo();
            _this.chgnum();
        });
	    
	    /*************事件：关闭*************/
        $("#aClose").click(function(){
            window.close();
        });
    },
    /**
    *人效修改
    */
    chgnum:function(){
        var _this = this;
        if (!this.PeopleNumChgForm) {
            this.PeopleNumChgForm = new Chenxin.UI.PeopleNumChgForm({
                scrop: _this,
                alwaysCheckPermit: true,
                saveSucc:function(){
                    _this.grid.reload();
			    },
			    afterGetFormJson: function(json) {
                }
            });
        }
        this.PeopleNumChgForm.op = "ChgNum";
        if(this.PeopleNumChgForm.show(this.PeopleNumChgForm.op)){
            this.PeopleNumChgForm.reset();
            var _data = this.currentNum;
            this.PeopleNumChgForm.fitData(_data);
            this.PeopleNumChgForm.setTitle('人效修改');
        }
    },
    exportAll: function() {
            _this = this;
            paramStr = this.search.getParamJson();
            paramStr.op = 'exportAll';
            Chenxin.Msg.Waiting.show();
            Chenxin.Fn.exportToExcelByServer(this.actionUrl, paramStr, '导出文件');
            //$.ajax({ url: this.actionUrl, data: paramStr,async:false});
            Chenxin.Msg.Waiting.hide();
    }
});

/**
*查询面板
*/
Chenxin.UI.ShowListEmployeeSearch=Chenxin.extend(Chenxin.UI.SearchCommon,{
    id:'ShowListEmployee_search',
    initEvent:function(){
        var _this=this; 

        //查询按钮
        $('#btEfficency').click(function(){
              _this.scope.reloadGrid("",0);
        });
    },
    createComboList: function(){
        //月份
        var ComboMonth = new Chenxin.UI.Combo({
            containerId: '#month',
            tbxWidth: 15,
            colWidth: 15,
            items: comboCommon.EfficencyMonth
        });
        
        //职务类型
        var ComboPosition = new Chenxin.UI.Combo({
            containerId: '#Position',
            tbxWidth: 45,
            colWidth: 40,
            items: comboCommon.EfficencyPosition
        });

        //五级联Combo
        var combl = new Chenxin.UI.StructComboList();
        var structs = combl.comboList;
        structs.push(ComboPosition);
        structs.push(ComboMonth);
        return structs;
    },
    initComponent: function() {
        Chenxin.UI.ShowListEmployeeSearch.superclass.initComponent.call(this);
    }
});

$(document).ready(function(){
    var showlistemployee = new Chenxin.UI.ShowListEmployee();
});